package com.shushan.pages.newtype.bean;

import com.android.net.bean.NetBaseBean;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;

/**
 * @ClassName: NewWordBean
 * @Desciption: //生字列表子项数据bean
 * @author: zhangshihao
 * @date: 2018-07-23
 */
public class NewWordBean extends NetBaseBean {

    public int id;
    public String name;
    public int bihua;
    public String jiegou;
    public String bushou;
    public String zuci;
    public String gif_url;

    private ArrayList<StrangeWordsPhraseItemBean> phraseItemBeans = new ArrayList<>();

    @Override
    public void initByJson(JSONObject jsonObject) throws JSONException {
        if(jsonObject == null){
            return;
        }
        id = jsonObject.optInt("id",0);
        name = jsonObject.optString("name","");
        bihua = jsonObject.optInt("bihua",0);
        jiegou = jsonObject.optString("jiegou","");
        bushou = jsonObject.optString("bushou","");
        zuci = jsonObject.optString("zuci","");
        gif_url = jsonObject.optString("gif_url","");

        JSONArray phraseArr = jsonObject.optJSONArray("phrase");
        if(phraseArr != null && phraseArr.length() > 0){
            for(int i=0;i<phraseArr.length();i++){
                JSONObject jobj = phraseArr.optJSONObject(i);
                StrangeWordsPhraseItemBean itemBean = new StrangeWordsPhraseItemBean();
                itemBean.initByJson(jobj);
                phraseItemBeans.add(itemBean);
            }
        }
    }

    public ArrayList<StrangeWordsPhraseItemBean> getPhraseItemBeans() {
        return phraseItemBeans;
    }

}
